﻿<%@ Application Language="VB" %>
<%@ Import Namespace="Cls_Common" %>
<%@ Import Namespace="SecurityService" %>
<script runat="server">
    Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        Application("OnlineUsers") = 1
        RegisterRouters(System.Web.Routing.RouteTable.Routes)
    End Sub
    
    Sub RegisterRouters(ByVal routers As System.Web.Routing.RouteCollection)

        routers.MapPageRoute("trangchu", "index.html", "~/index.aspx")

        routers.MapPageRoute("TracuuMotCua", "tra-cuu-mot-cua.html", "~/Page/TiepNhan/TraCuuMotCua.aspx")
        
        routers.MapPageRoute("sitemap", "sitemap.html", "~/FrontEnd/Page/sitemap.aspx")
        routers.MapPageRoute("gioithieu", "gioi-thieu.html", "~/FrontEnd/Page/GioiThieu.aspx")
        routers.MapPageRoute("bo-sung", "bo-sung-ho-so.html", "~/FrontEnd/Page/BoSungHoSo.aspx")
        'vbpq        
        routers.MapPageRoute("vbpq", "van-ban-phap-luat.html", "~/FrontEnd/Page/VBPQ/List.aspx")
        routers.MapPageRoute("vbpqchitieten", "van-ban-phap-luat/{SoHieuVanBan}-{Id}.html", "~/FrontEnd/Page/VBPQ/Detail.aspx")
        
        
        routers.MapPageRoute("tin-tuc", "tin-tuc.html", "~/FrontEnd/Page/News.aspx")
        routers.MapPageRoute("san-pham.html", "san-pham.html", "~/FrontEnd/Page/AllCate.aspx")
        routers.MapPageRoute("lien-he.html", "lien-he.html", "~/FrontEnd/Page/Contact.aspx")
        routers.MapPageRoute("dich-vu-thong-tin.html", "dich-vu-thong-tin.html", "~/FrontEnd/Page/DichVuThongTin.aspx")
        routers.MapPageRoute("thu-tuc-hanh-chinh.html", "thu-tuc-hanh-chinh.html", "~/FrontEnd/Page/DichVuThongTin.aspx")
        routers.MapPageRoute("bo-sung-chuan-hoa-du-lieu.html", "bo-sung-chuan-hoa-du-lieu.html", "~/FrontEnd/Page/BoXungChuanHoaDuLieu.aspx")
        routers.MapPageRoute("dich-vu-cong.html", "dich-vu-cong.html", "~/FrontEnd/Page/DichVuTrucTuyen.aspx")
        'tra cuu
        routers.MapPageRoute("tracuu", "tra-cuu-ho-so.html", "~/FrontEnd/Page/TraCuuGCN.aspx")
        routers.MapPageRoute("nganhngheKDCoDK", "nganh-nghe-kinh-doanh-co-dieu-kien.html", "~/FrontEnd/Page/NganhNgheKDCoDK.aspx")
        routers.MapPageRoute("ketquatinkiem", "ket-qua-tim-kiem.html", "~/FrontEnd/Page/News/Search.aspx")
        'routers.MapPageRoute("khuyen-mai.html", "khuyen-mai.html", "~/FrontEnd/Page/Promotion.aspx")
        routers.MapPageRoute("phan-hoi.html", "phan-hoi.html", "~/FrontEnd/Page/Contact.aspx")
        routers.MapPageRoute("timsanpham", "tim-kiem.html", "~/FrontEnd/Page/Product/Search.aspx")
        'routers.MapPageRoute("gio-hang.html", "gio-hang.html", "~/FrontEnd/Page/ShoppingCart.aspx")
        routers.MapPageRoute("myAdmin.html", "myAdmin.html", "~/FrontEnd/Page/Member/myAdmin.aspx")
        routers.MapPageRoute("giaydenghidangky", "giay-de-nghi-dang-ky.html", "~/FrontEnd/Page/Member/DangKyKDCreate.aspx")
        routers.MapPageRoute("giaydenghisuadangky", "sua-giay-de-nghi-dang-ky.html", "~/FrontEnd/Page/Member/DangKyKDEdit.aspx")
         routers.MapPageRoute("xemgiaydenghidangky", "xem-giay-de-nghi-dang-ky.html", "~/FrontEnd/Page/Member/DangKyKDDetail.aspx")
        routers.MapPageRoute("giaydenghicapdoi", "giay-de-nghi-cap-doi.html", "~/FrontEnd/Page/Member/DangKyKDCapDoi.aspx")
        routers.MapPageRoute("thong-tin-ca-nhan.html", "thong-tin-ca-nhan.html", "~/FrontEnd/Page/Member/Profiles.aspx")
        routers.MapPageRoute("doi-mat-khau.html", "doi-mat-khau.html", "~/FrontEnd/Page/Member/ChangePass.aspx")
        routers.MapPageRoute("quen-mat-khau.html", "quen-mat-khau.html", "~/FrontEnd/Page/Member/ForgotPassword.aspx")
        
        'routers.MapPageRoute("my-shoppingCart.html", "my-shoppingCart.html", "~/FrontEnd/Page/Member/MyCart.aspx")
        'routers.MapPageRoute("chi-tiet-shoppingCart.html", "chi-tiet-shoppingCart.html", "~/FrontEnd/Page/Member/DetailMyCart.aspx")
        routers.MapPageRoute("hotro", "ho-tro.html", "~/FrontEnd/Page/HoTro.aspx")
        
        'Store
        routers.MapPageRoute("StoreCreate", "tao-moi-ho-kinh-doanh.html", "~/FrontEnd/Page/Store/Create.aspx")
        routers.MapPageRoute("StoreEdit", "thong-tin-ho-kinh-doanh.html", "~/FrontEnd/Page/Store/Edit.aspx")
        routers.MapPageRoute("DSSanPham", "quan-ly-san-pham.html", "~/FrontEnd/Page/Product/List.aspx")
        routers.MapPageRoute("TaoMoiSP", "tao-moi-san-pham.html", "~/FrontEnd/Page/Product/Create.aspx")
        routers.MapPageRoute("ChinhSuaSP", "chinh-sua-san-pham.html", "~/FrontEnd/Page/Product/Edit.aspx")
        routers.MapPageRoute("StoreByHome", "ho-kinh-doanh.html", "~/FrontEnd/Page/StoreByHome.aspx")
        routers.MapPageRoute("StoreTrangChu", "ho-kinh-doanh/{QueryString}-{Id}.html", "~/FrontEnd/Page/Store.aspx")
        routers.MapPageRoute("StoreGioiThieu", "{QueryString}-{Id}/gioi-thieu.html", "~/FrontEnd/Page/Store/GioiThieu.aspx")
        routers.MapPageRoute("StoreContact", "{QueryString}-{Id}/lien-he.html", "~/FrontEnd/Page/Store/Contact.aspx")
        routers.MapPageRoute("StoreMap", "{QueryString}-{Id}/ban-do.html", "~/FrontEnd/Page/Store/Map.aspx")
        routers.MapPageRoute("storesanpham", "{QueryString}-{Id}/san-pham.html", "~/FrontEnd/Page/Store/ListProduct.aspx")
       
        
        routers.MapPageRoute("CNews", "tin-tuc-su-kien-{MenuId}.html", "~/FrontEnd/Page/News/NewsByMenu.aspx")
        
        
         
        routers.MapPageRoute("gallery", "gallery-{MenuId}.html", "~/FrontEnd/Page/News/NewsByMenu.aspx")
               
         'Content By cat        
        routers.MapPageRoute("ContentsByCat", "{QueryString}-{MenuId}c.html", "~/FrontEnd/Page/Contents/ContentByCat.aspx")
        
        'Header Menu
        routers.MapPageRoute("thanhvien", "thanh-vien.html", "~/FrontEnd/Page/ThanhVien.aspx")
        routers.MapPageRoute("quanlyRaoVatCreate", "dang-tin-ban-oto.html", "~/FrontEnd/Page/RaoVat/Create.aspx")
        routers.MapPageRoute("dangnhap", "dang-nhap.html", "~/FrontEnd/Page/Login.aspx")
        routers.MapPageRoute("dangky", "dang-ky.html", "~/FrontEnd/Page/Register.aspx")
        routers.MapPageRoute("changepassword", "doi-mat-khau.html", "~/FrontEnd/Page/ChangePassword.aspx")
        
        routers.MapPageRoute("thongtincanhan", "thong-tin-ca-nhan.html", "~/FrontEnd/Page/Profile.aspx")
       
         routers.MapPageRoute("storesanphamChitiet", "{QueryString}-{Id}/{QueryString2}-{ProductId}.html", "~/FrontEnd/Page/Product/Detail.aspx")
        'menu-content
          'routers.MapPageRoute("SalonTrangChu", "store/{QueryString}-{Id}.html", "~/FrontEnd/Page/Store.aspx")
        
        'routers.MapPageRoute("storegioithieu", "shop/{QueryString}-{Id}/gioi-thieu.html", "~/FrontEnd/Page/StoreIntro.aspx")
        'routers.MapPageRoute("storelienhe", "shop/{QueryString}-{Id}/lien-he.html", "~/FrontEnd/Page/StoreLienHe.aspx")
        'routers.MapPageRoute("storesanpham", "shop/{QueryString}-{Id}/san-pham.html", "~/FrontEnd/Page/StoreProduct.aspx")
        'routers.MapPageRoute("SalonBanDo", "shop/{QueryString}-{Id}/ban-do.html", "~/FrontEnd/Page/StoreBanDo.aspx")
        
        ' routers.MapPageRoute("storeListsanpham", "shop/{QueryString}-{Id}/{CateQueryString}-{CateId}.html", "~/FrontEnd/Page/StoreProductList.aspx")
        ' routers.MapPageRoute("StoreProductResutl", "{QueryString}-{Id}/tim-san-pham.html", "~/FrontEnd/Page/ProductSearchResultByStore.aspx")
   
        
      
        '  routers.MapPageRoute("sanphamdetail", "{ProductQueryString}-{ProductId}.html", "~/FrontEnd/Page/Product/Detail.aspx")
       
        'san pham by cat
        ' routers.MapPageRoute("sanphamcate", "san-pham/{QueryString}-{CateId}.html", "~/FrontEnd/Page/Product/ListProductByCate.aspx")
        
        
        routers.MapPageRoute("nhanhtin", "{QueryString}-{MenuId}.html", "~/FrontEnd/Page/Menu/Detail.aspx")
        
        
        
        routers.MapPageRoute("Content", "content/{QueryString}-{Id}.html", "~/FrontEnd/Page/Content.aspx")
        'salon trang chu
       

        routers.MapPageRoute("timCuaHang", "tim-kiem-cua-hang.html", "~/FrontEnd/Page/StoreSearch.aspx")
        
       
        routers.MapPageRoute("timraoVat", "tim-kiem-rao-vat.html", "~/FrontEnd/Page/RaovatSearch.aspx")
        
        'Tin tuc
  
        routers.MapPageRoute("tin-tuc-list", "tin-tuc/{QueryString}-{Id}.html", "~/FrontEnd/Page/News/NewsByMenu.aspx")
        routers.MapPageRoute("News", "{MenuId}/{QueryString}-{Id}s.html", "~/FrontEnd/Page/News/NewsDetail.aspx")
        routers.MapPageRoute("Album", "{MenuId}/{QueryString}-{Id}a.html", "~/FrontEnd/Page/News/Album.aspx")
        routers.MapPageRoute("Videos", "{MenuId}/{QueryString}-{Id}v.html", "~/FrontEnd/Page/News/Video.aspx")
        routers.Ignore("{resource}.axd/{*pathInfo}")

    End Sub
    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application shutdown
    End Sub
        
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
      
    End Sub

    
    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
        Session("UserName") = Nothing
        Session("UserID") = Nothing
        Session("RoleID") = Nothing
        Session("MenuId") = Nothing
        Session("UserCode") = Nothing
        Session("LanguageId") = 1
        Session("CartId") = Guid.NewGuid().ToString
        Session("LastLogin") = Now
        Application.Lock()
        Application("OnlineUsers") = CType(Application("OnlineUsers"), Integer) + 1
        'update Counter
        Using data As New VSModel.VSEntities
            data.Update_HitCounter()
        End Using
        Application.UnLock()
        
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a session ends. 
        ' Note: The Session_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer 
        ' or SQLServer, the event is not raised.
        Session("UserName") = Nothing
        Session("MenuId") = Nothing
        Session("UserCode") = Nothing
    End Sub
       
</script>